package com.lfy.fyadmin.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lfy.fyadmin.entity.RolePermission;
import com.lfy.fyadmin.service.RolePermissionService;
import com.lfy.fyadmin.mapper.RolePermissionMapper;
import org.springframework.stereotype.Service;

/**
* @author 53409
* @description 针对表【role_permission(角色权限关联表)】的数据库操作Service实现
* @createDate 2025-07-23 21:51:27
*/
@Service
public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, RolePermission>
    implements RolePermissionService{

    @Override
    public boolean updateSelective(RolePermission rolePermission) {
        return this.baseMapper.updateSelective(rolePermission) > 0;
    }

    @Override
    public IPage<RolePermission> getRolePermissionWithRoleId(Page<RolePermission> page,
                                                             Long roleId) {

        if (roleId != null){

            return this.page(page, Wrappers
                    .lambdaQuery(RolePermission.class)
                    .eq(RolePermission::getRoleId, roleId));
        }

        return this.page(page);
    }
}




